home *** CD-ROM | disk | FTP | other *** search
Text File | 1994-01-16 | 7.5 KB | 260 lines | [TEXT/MMCC] |
- /* Copyright © 1994 George R. Cossey */
- /* mmMenuMM_Demo Handle menus
-
- File name: mmMenuMM_Demo
- Function: This contains the routines to handle menus.
- History: 1/16/94 Original by George Cossey
-
- */
-
- #include "mmCommonMM_Demo.h" /* Common */
- #include "CommonMM_Demo.h" /* Common */
-
-
- /* ======================================================= */
- /* ======================================================= */
-
- /* Routine: Init */
- /* Purpose: Load in the menu lists and initialize the menubar */
-
- void CmmMenus::Init() /* Initialize the menu bar */
- {
-
- ClearMenuBar(); /* Clear any old menu bars */
-
- /* This menu is */
- Menu_Apple = GetMenu(Res_Menu_Apple); /* Get the menu from the resource file */
- InsertMenu(Menu_Apple,0); /* Insert this menu into the menu bar */
- AddResMenu(Menu_Apple,'DRVR'); /* Add in DAs */
-
- /* This menu is File */
- Menu_File = GetMenu(Res_Menu_File); /* Get the menu from the resource file */
- InsertMenu(Menu_File,0); /* Insert this menu into the menu bar */
-
- /* This menu is Edit */
- Menu_Edit = GetMenu(Res_Menu_Edit); /* Get the menu from the resource file */
- InsertMenu(Menu_Edit,0); /* Insert this menu into the menu bar */
-
- /* This menu is Windows */
- Menu_Windows = GetMenu(Res_Menu_Windows); /* Get the menu from the resource file */
- InsertMenu(Menu_Windows,0); /* Insert this menu into the menu bar */
-
-
- this->AddExtraMenus(); /* Add any extra menu lists */
-
- DrawMenuBar(); /* Draw the menu bar */
- }
-
- /* ======================================================= */
-
- /* Routine: AddExtraMenus */
- /* Purpose: Add in more menus */
-
- void CmmMenus::AddExtraMenus()
- {
- /* Expected to be overridden by the user code */
- }
-
- /* ======================================================= */
-
- /* Routine: EnableTheMenus */
- /* Purpose: Enable or disable menus before they are pulled down */
-
- void CmmMenus::EnableTheMenus()
- {
- /* Expected to be overridden by the user code */
- }
-
- /* ======================================================= */
-
- /* Routine: DoMenuApple */
- /* Purpose: Handle all menu items in this list */
-
- Boolean CmmMenus::DoMenuApple(short theItem)
- {
- short DNA; /* For opening DAs */
- Str255 DAName; /* For getting DA name */
- GrafPtr SavePort; /* Save current port when opening DAs */
- Boolean HandledTheMenuItem;
-
-
- HandledTheMenuItem = true;
- switch (theItem) /* Handle all commands in this menu list */
- {
- case MItem_About_Demo: /* For item About Demo… */
- gAbout_Demo->Open(); /* Open this modeless dialog */
- break;
- default: /* allow other buttons, trap for debug */
- GetPort(&SavePort); /* Save the current port */
- GetItem(Menu_Apple,theItem, DAName); /* Get the name of the DA selected */
- DNA = OpenDeskAcc(DAName); /*Open the DA selected */
- SetPort(SavePort); /* Restore to the saved port */
- HandledTheMenuItem = false;
- break; /* end of otherwise */
- } /* end of switch */
- return(HandledTheMenuItem);
- }
-
- /* ======================================================= */
-
- /* Routine: DoMenuFile */
- /* Purpose: Handle all menu items in this list */
-
- Boolean CmmMenus::DoMenuFile(short theItem)
- {
- Boolean HandledTheMenuItem;
-
-
- HandledTheMenuItem = true;
- switch (theItem) /* Handle all commands in this menu list */
- {
- case MItem_New: /* For item New */
- break;
- case MItem_Open: /* For item Open… */
- gFiles->Open_The_File(); /* Do file open */
- break;
- case MItem_Close: /* For item Close */
- break;
- case MItem_Save: /* For item Save */
- gFiles->Save_The_File(); /* Do file save */
- break;
- case MItem_Save_As: /* For item Save As… */
- gFiles->Save_The_File(); /* Do file save */
- break;
- case MItem_Revert: /* For item Revert */
- break;
- case MItem_Page_Setup: /* For item Page Setup… */
- gPrinting->PageSetup(); /* Do Printing PageSetup */
- break;
- case MItem_Print: /* For item Print… */
- gPrinting->Print_The_Data(); /* Do Printing */
- break;
- case MItem_Quit: /* For item Quit */
- doneFlag = true; /* Quit */
- break;
- default: /* allow other buttons, trap for debug */
- HandledTheMenuItem = false;
- break; /* end of otherwise */
- } /* end of switch */
- return(HandledTheMenuItem);
- }
-
- /* ======================================================= */
-
- /* Routine: DoMenuEdit */
- /* Purpose: Handle all menu items in this list */
-
- Boolean CmmMenus::DoMenuEdit(short theItem)
- {
- Boolean BoolHolder; /* For SystemEdit result */
- Boolean HandledTheMenuItem;
-
-
- HandledTheMenuItem = true;
- BoolHolder = SystemEdit(theItem - 1); /* Let the DA do the edit to itself */
-
- if (!BoolHolder) /* If not a DA then we get it */
- {
-
- switch (theItem) /* Handle all commands in this menu list */
- {
- case MItem_Undo: /* For item Undo */
- break;
- case MItem_Cut: /* For item Cut */
- break;
- case MItem_Copy: /* For item Copy */
- break;
- case MItem_Paste: /* For item Paste */
- break;
- case MItem_Clear: /* For item Clear */
- break;
- case MItem_Select_All: /* For item Select All */
- break;
- default: /* allow other buttons, trap for debug */
- HandledTheMenuItem = false;
- break; /* end of otherwise */
- } /* end of switch */
- }
- else
- HandledTheMenuItem = false;
- return(HandledTheMenuItem);
- }
-
- /* ======================================================= */
-
- /* Routine: DoMenuWindows */
- /* Purpose: Handle all menu items in this list */
-
- Boolean CmmMenus::DoMenuWindows(short theItem)
- {
- Boolean HandledTheMenuItem;
-
-
- HandledTheMenuItem = true;
- switch (theItem) /* Handle all commands in this menu list */
- {
- case MItem_Alert: /* For item Alert… */
- gMy_Alert->BringUpAlert(); /* Open this alert */
- break;
- case MItem_Modal_Dialog: /* For item Modal Dialog… */
- gMy_Modal->BringUpDialog(); /* Open this modal dialog */
- break;
- case MItem_Movable_Modal_D: /* For item Movable Modal Dialog… */
- gMy_Movable_Moda->Open(); /* Open this modeless dialog */
- break;
- case MItem_Modeless_Dialog: /* For item Modeless Dialog… */
- gMy_Modeless->Open(); /* Open this modeless dialog */
- break;
- case MItem_Window: /* For item Window… */
- gMy_basic_window->Open(); /* Open this window */
- break;
- case MItem_Floating_window: /* For item Floating window… */
- gFloating_window->Open(); /* Open this window */
- break;
- default: /* allow other buttons, trap for debug */
- HandledTheMenuItem = false;
- break; /* end of otherwise */
- } /* end of switch */
- return(HandledTheMenuItem);
- }
-
- /* ======================================================= */
-
- /* ======================================================= */
-
- /* Routine: HandleMenuSelection */
- /* Purpose: Vector off to the appropiate menu list handler */
-
- Boolean CmmMenus::HandleMenuSelection(short theMenu,short theItem)
- {
- Boolean HandledTheMenu;
-
-
- HandledTheMenu = true;
- switch (theMenu) /* Do selected menu list */
- {
- case Res_Menu_Apple:
- DoMenuApple(theItem); /* Go handle this list, */
- break;
- case Res_Menu_File:
- DoMenuFile(theItem); /* Go handle this list, File */
- break;
- case Res_Menu_Edit:
- DoMenuEdit(theItem); /* Go handle this list, Edit */
- break;
- case Res_Menu_Windows:
- DoMenuWindows(theItem); /* Go handle this list, Windows */
- break;
-
- default: /* allow other buttons, trap for debug */
- HandledTheMenu = false;
- break; /* end of otherwise */
- } /* end of switch */
-
- HiliteMenu(0); /* Turn menu selection off */
- return(HandledTheMenu);
- }
-
- /* ======================================================= */
- /* ======================================================= */
-